<template>
    <div class="app-container">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="微信支付" name="first">
          <el-form ref="form" :model="form" label-width="110px">
            <el-form-item label="商户号">
              <el-input v-model="form.appid"></el-input>
            </el-form-item>
            <el-form-item label="服务商商户ID">
              <el-input v-model="form.scckey"></el-input>
            </el-form-item>
            <el-form-item label="服务商Key">
              <el-input v-model="form.shnum"></el-input>
            </el-form-item>
            <el-form-item label="是否开启">
              <el-radio-group v-model="form.status">
                <el-radio :label="1">开启</el-radio>
                <el-radio :label="2">关闭</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="onSubmit">修改</el-button>
              <el-button>取消</el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="支付宝支付" name="second">
          <el-form ref="form" :model="form1" label-width="110px">
            <el-form-item label="商户号">
              <el-input v-model="form1.appid"></el-input>
            </el-form-item>
            <el-form-item label="服务商商户ID">
              <el-input v-model="form1.scckey"></el-input>
            </el-form-item>
            <el-form-item label="服务商Key">
              <el-input v-model="form1.shnum"></el-input>
            </el-form-item>
            <el-form-item label="公钥">
              <el-input v-model="form1.gy" type="textarea"></el-input>
            </el-form-item>
            <el-form-item label="私钥">
              <el-input v-model="form1.sy" type="textarea"></el-input>
            </el-form-item>
            <el-form-item label="是否开启">
              <el-radio-group v-model="form1.status">
                <el-radio :label="1">开启</el-radio>
                <el-radio :label="2">关闭</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="onSubmit1">修改</el-button>
              <el-button>取消</el-button>
            </el-form-item>
          </el-form>

        </el-tab-pane>
      </el-tabs>

    </div>
  </template>
  
  <script>
  import { getpayList,getpayEdit } from '@/api/config'
  export default {
    name: 'ComplexTable',
    data() {
      return {
        activeName: 'first',
        form: {
          appid: '',
          scckey: '',
          shnum: '',
          types: 1,
          status:1
        },
        form1: {
          appid: '',
          scckey: '',
          shnum: '',
          types: 2,
          gy:'',
          sy:'',
          status:2
        }
      }
    },
    created() {
     this.getpayLists()
     this.getpayLista()
    },
    methods: {
      //获取配置信息
      getpayLists(){
          getpayList({id:1}).then(response => {
              console.log(response.data)
              this.form = response.data
          })
      },
      getpayLista(){
          getpayList({id:2}).then(response => {
              console.log(response.data)
              this.form1 = response.data
          })
      },
      onSubmit() {
        console.log('submit!');
        getpayEdit(this.form).then(response => {
              this.$notify({
                title: 'Success',
                message: 'Update Successfully',
                type: 'success',
                duration: 2000
              })
              this.getpayLists()
              this.getpayLista()
          })
      },
      onSubmit1(){
        getpayEdit(this.form1).then(response => {
              this.$notify({
                title: 'Success',
                message: 'Update Successfully',
                type: 'success',
                duration: 2000
              })
              this.getpayLists()
              this.getpayLista()
          })

      },
      handleClick(tab, event) {
        console.log(tab, event);
      }
    }
  }
  </script>
  <style lang="scss" scoped>
  </style>